<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title><?php echo $_GET['goods']?>详情页</title>
		<link href="css/details.css" type="text/css" rel="stylesheet">
	</head>
	<body>
		<?php 
			require("/include/menu.php");		//导入头部
			include("../public/config.php");	//导入数据库配置文件
			date_default_timezone_set("PRC");
			$link = @mysqli_connect(HOST,USER,PASS,DBNAME) or die("数据库连接失败！");//连接数据库
			mysqli_set_charset($link,"utf8");	//设置数据库编码
		?>
			<!-- 网页主体开始 -->
			<div class="container">
			<div class="details_name">
			<?php
				$sql = "select t.name from goods g,type t where g.typeid=t.id and goods='{$_GET['goods']}'";			//设置SQL语句进行联合查询，查找面包屑导航栏目名称
				// echo $sql;
				$res = mysqli_query($link,$sql);	//发送执行sql语句
				$goods = mysqli_fetch_assoc($res);	//取出结果集
				// echo $goods['name'];
			 ?>
			 	<!-- 输出面包屑导航 -->
				<a href="index.php">首页</a> >&nbsp;<?php echo $goods['name'];?>>&nbsp;<?php echo $_GET['goods'];?>				
			</div>
			<?php
				// 根据列表页传来的参数进行查询数据库，查找数据库里面的详细页信息
				$sql = "select * from goods where goods = '{$_GET['goods']}' order by addtime desc";
				$result = mysqli_query($link,$sql);		//发送sql语句并执行
				$row = mysqli_fetch_assoc($result);		//解析结果集
				// echo $sql;
			?>
			<!-- 面包屑导航结束 -->

			<!-- 购物车以及立即下单开始 -->
					<div class="details_top_left">
						<?php
							// 输出详情页的顶部左侧图片信息
							echo '<div class="left_top"><img src="../public/uploads/'.$row[picname].'"></div>';
							echo '<div class="left_bottom">';

							echo '<ul>';		//输出五张小图片
							for($i=0;$i<5;$i++){
								echo '<li><img src="../public/uploads/s_'.$row[picname].'"></li>';
							}
							echo '</ul>';
							echo '</div>';
						?>
						
					</div>
					<div class="details_top_right">
					<div class="right_top">
						<?php
							echo '<p>'.$row[goods].'</p>';		//输出商品名称(右侧)

						?>
						<span>精致外观，双1200万像素平行镜头，5.7英寸2K屏，搭载麒麟950系列芯片，3500mAh电池长久续航；如有异见，不如一见！</span>
					</div>
					<div class="right_center">
					<!-- 输出价格 -->
						<p>价格: <span style="color: red;font-size: 25px;">¥ <?php echo $row['price']?></span></p>
						<!-- 输出编码 -->
						<p>编码: <span><?php echo date("Ymd").$row['id']?></span></p>
						<p>运费: <span>满 99 免运费</span></p>
						<p>服务：<span>由华为商城负责发货，并提供售后服务</span></p>
					</div>
					<div class="right_bottom">
					<!-- 输出小图片 -->
						<img src="../public/uploads/s_<?php echo $row['picname'];?>">
					</div>
					<div class="right_input">
						<a href="shoping/buycar.php?a=add&id=<?php echo $row[id]?>&goods=<?php echo $row[goods]?>">加入购物车</a>
					</div>
				</div>
			</div>

			<div class="clear"></div>
			<div class="container">	
			<div class="details_bg01" style="width:1200px;height: 500px;">
				<!-- 输出商品详情 -->
				<?php echo $row['descr']?>	
						<!-- 输出详情页图片 -->
				<img src="../public/uploads/<?php echo $row['picname']?>" style="display:block;width: 400px;">
				</div>
			</div>
			<div class="clear"></div>
			<div style="margin-bottom: 30px">
				<div class="container">
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<th width="20%">评论账号</th>
							<th width="50%">评论内容</th>
							<th width="30%">评论时间</th>
						</tr>
						<?php
							$sql = "select * from comment where goodsid='{$_GET['goodsid']}' order by addtime desc";
							$res = mysqli_query($link,$sql);
							
							while ($row = mysqli_fetch_assoc($res)) {
								$sql2 = "select * from users where id='{$row['uid']}'";
								$res2 = mysqli_query($link,$sql2);
								$use = mysqli_fetch_assoc($res2);
								echo '<tr align="center">';
								echo '<td>'.$use['username'].'</td>';
								echo '<td>'.$row['connect'].'</td>';
								echo '<td>'.date("Y-m-d H:i:s",$row['addtime']).'</td>';
								echo '</tr>';
							}
						?>		
					</table>
				</div>
			</div>
			<div class="container">
				<?php include("./include/webbottom.php");?>
			</div>
	</body>
</html>